home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-26 | 4.9 KB | 180 lines | [TEXT/MPS ] |
- #
- # File: ThreeWayMergeBranch
- #
- # Contains: xxx put contents here xxx
- #
- # ThreeWayMergeBranch - Merges any changes you have locally with the current
- # latest version on your Named Branch (or main branch if you don't have one).
- # The resulting merge is placed into a modified readonly file that is derived
- # from the latest version.
- #
- # You can use this to merge in changes from other branches by checking them
- # out and then doing a merge.
- #
- # Usage: ThreeWayMergeBranch file
- #
- # ThreeWayMergeBranch is a variation on the traditional MergeBranch.
- # It renames the branch revision "file" to "file",branch and
- # checks out the latest revision on the revision trunk modified read only.
- #
- # It also checks out the version of the file from which your
- # local was derived (either checked out for modify or modified read only).
- # This file is called the base. Your version is version1, while the
- # current main branch is version2. We then call ThreeWayMergeBranch
- # to merge the changes automatically. The result is that you are up-to-date
- # with the main branch, and can check in after you have verified that
- # the merge was successful. Note that ThreeWayMergeBranch marks
- # conflicts with lines containing •••.
- #
- # To add MergeBranch to a menu, execute the following command:
- #
- # AddMenu Project 'ThreeWayMergeBranch' ∂
- # 'ThreeWayMergeBranch "{Active}" ∑∑ "{WorkSheet}"'
- #
- # This script creates many temporary files, in the {temporary} folder,
- # which are deleted on exit or abort. It leaves your original file and
- # the base.
- #
- # ThreeWayMergeBranch calls the script ThreeWayMerge.
- #
- # Owned by: Jens Alfke
- #
- # Copyright: © 1988 - 1990, 1995-1996 by Apple Computer, Inc., all rights reserved.
- #
- # Change History (most recent first):
- #
- # <1> 5/25/95 jpa first checked in
- #
- # To Do:
- #
-
-
- Set Exit 1
- Begin
-
- # Check parameters.
-
- If {#} ≠ 1
- Echo "### Usage - {0} file"
- Exit 0
- End
-
- # Make sure the file exists
-
- If "" == "`Exists -f "{1}"`"
- Echo "### {0} - File ∂"{1}∂" not found"
- Exit 4
- End
-
- # Break apart the pathname.
-
- Set f "{1}"
- If "{f}" =~ /(≈)®1:([¬:]+)®2/
- Set dir "{®1}:"
- Set f "{®2}"
- Else
- Set dir `directory`
- End
-
- Set path "{dir}{f}"
-
- # Get project information on the file.
- Set info1 "`projectinfo "{path}"`"
-
- If "{info1}" =~ /[∂']*(≈)®1,([¬ ∂']+)®2[∂']* ≈Project: (≈∫)®3≈ Task: (≈)®4/
- Set file "{®1}"
- Set rev "{®2}"
- Set proj "{®3}"
- Set task "{®4}"
- Set comment "Merged from branch {rev}."
- End
-
-
- # If the file is checked out for modification, check it in
- # and call projectinfo again to get the branch's new revision number.
-
- If "{rev}" =~ /≈∂+/
- CheckIn -y "{path}" ≥dev:null
- Set info1 "``projectinfo "{path}"``"
- If "{info1}" =~ /[∂']*(≈)®1,([¬ ∂']+)®2[∂']* ≈Project: (≈∫)®3≈/
- Set file "{®1}"
- Set rev "{®2}"
- Set proj "{®3}"
- End
- End
-
- # build an argument indicating our current Branch Name
- set NameSpec ""
- if "{gMyBranchName}" ≠ ""
- set NameSpec "-n ∂"{gMyBranchName}∂""
- End
-
- # Get projectinfo on the file's latest revision for the NameBranch you are workin on
-
- Set info2 "`projectinfo {nameSpec} -s -project "{proj}" "{f}" ≥ dev:null`"
- If "{info2}" == ""
- Alert "Project ∂"{proj}∂" is not mounted."
- Exit 4
- End
-
- If "{info2}" =~ /∂'[¬,]+,([¬ ∂']+)®2∂'≈/
- Set latestRev "{®2}"
- Else If "{info2}" =~ /[¬,]+,([¬ ]+)®2 ≈/
- Set latestRev "{®2}"
- Else
- Alert "Latest rev of File ∂"{f}∂" is checked out for modification. Cannot merge at this time."
- Exit 4
- End
-
- Set OldExit Exit
- Set Exit 0
- Close "{path}" ≥≥ dev:null
- Set Exit {OldExit}
-
- # figure out what version we branched from
- set revBase "`FindCommonBaseRevision "{rev}" "{latestRev}"`"
-
- if "{revBase}" == "{rev}"
- Echo "### For file ∂"{file}∂", latest {latestRev} is derived from your {rev}"
- # checkout current latest version
- CheckOut "{path},{latestRev}" -project "{proj}"
- Else
- # Rename the branch revision and checkout the trunk revision for modification.
-
- Set branchf "{path},{rev}"
- Duplicate -y "{path}" "{TempFolder}{file}"
- Rename -y "{path}" "{branchf}"
-
- # go and get the original version that we branched off of
- Set branchBase "{path},{revBase}"
- CheckOut "{branchBase}" -project "{proj}"
- Rename -y "{path}" "{branchBase}"
-
- # checkout current latest version
- CheckOut "{path},{latestRev}" -project "{proj}"
-
- # lets just see if there is nothing to do first...
- Set Exit 0
- Equal -q "{branchf}" "{path}"
- Set MyStatus {Status}
- Set Exit 1
-
- If {MyStatus} == 0
- Echo "### For file ∂"{path}∂", {rev} and {latestRev} are equal"
- Else
- Echo "### For file ∂"{path}∂", your {rev} merged with {latestRev} based on {revBase}"
-
- # use my nifty new script
- ThreeWayMerge "{branchBase}" "{branchf}" "{path}" > "{path}"•Merge
- Set MyStatus {Status}
-
- ModifyReadOnlyBranch "{path}"
- Catenate "{path}"•Merge > "{path}"
- Delete "{path}"•Merge
- End
- Delete "{branchf}" # original file
- Delete "{branchBase}" # base on which the comparison was made
- End
- End
-
-